﻿#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//常用拷贝算法和替换算法replace
class MyPrint
{
public:
	void operator()(int val)
	{
		cout << val << "  ";
	}
};
void test01()
{
	vector<int>v;
	v.push_back(20);
	v.push_back(30);
	v.push_back(60);
	v.push_back(70);
	v.push_back(90);
	v.push_back(20);
	v.push_back(20);
	//替换前的数据
	for_each(v.begin(), v.end(), MyPrint());
	//替换后的数据
	replace(v.begin(), v.end(), 20, 2000);
	cout << endl;
	for_each(v.begin(), v.end(), MyPrint());
}
int main()
{
	test01();
}